<template>
	<el-dialog :title="'审核_'+userName" :close-on-click-modal="false" :visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="600px">
		<el-row :gutter="15" class="" >
			<el-form ref="elForm" :model="dataForm" size="medium" label-width="100px" label-position="right" :disabled="!!isDetail" :rules="rules">
				<el-col :span="24">
					<el-form-item label="备注" prop="remark" required >
						<el-input v-model="dataForm.remark" placeholder="请输入" show-word-limit :style='{"width":"100%"}' type="textarea" :autosize='{"minRows":4,"maxRows":4}' >
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="附件" prop="attachmentInfo" required >
						<JNPF-UploadImg v-model="attachmentInfoList" accept="" :fileSize="2" sizeUnit="MB" :limit="9" >
						</JNPF-UploadImg>
					</el-form-item>
				</el-col>
			</el-form>
		</el-row>
		<span slot="footer" class="dialog-footer">
			<el-button @click="visible = false">取 消</el-button> 

      <el-button type="danger" @click="dataFormSubmit(2)" v-if="!isDetail">驳回</el-button>

			<el-button type="primary" @click="dataFormSubmit(1)" v-if="!isDetail">确 定</el-button>
		</span>
	</el-dialog>

</template>
<script>
import request from '@/utils/request'
import {getDictionaryDataSelector}from '@/api/systemData/dictionary'
import {previewDataInterface}from '@/api/systemData/dataInterface'
export default {
    data() {
      return {
        visible: false,
        isDetail: false,

        userName:"",
      dataForm: {
					remark:undefined,
          type:0,
					attachmentInfo:[],

        },
        rules: {
						remark:[
						{
							required:true,
							message:'请输入备注',
							trigger:'blur'
						},
						],
						attachmentInfo:[
						{
							required:true,
							message:'请输入附件',
							trigger:'blur'
						},
						],

        },

					attachmentInfoList:[],

      }
    },
    created() {

    },
    methods: {

           goBack() {
                    this.$emit('refresh')
                },
      init(id, row) {

        this.dataForm.id = id || 0;
        this.visible = true;
       this.userName = row.userName;
        this.$nextTick(() => {
          this.$refs['elForm'].resetFields();
         
        })
      },
      // 表单提交
      dataFormSubmit(type) {
				this.$set(this.dataForm, 'attachmentInfo', JSON.stringify(this.attachmentInfoList));
        this.dataForm.type = type;
        this.$refs['elForm'].validate((valid) => {
          if (valid) {
            request({
                url: '/api/jiushi/Pointswithdrawal/' + this.dataForm.id,
                method: 'PUT',
                data: this.dataForm
              }).then((res) =>{
                this.$message({
                  message: res.msg,
                  type: 'success',
                  duration: 1000,
                  onClose: () =>{
                    this.visible = false;
                    this.$emit('refresh', true);
                  }
                })
              })
            
          }
        })
      },

    }
  }
  </script>